CSharpTest.Net
Run(String[]) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Run Method : Run(String[]) Method

arguments

Glossary Item Box

Run the command whos name is the first argument with the remaining arguments provided to the command as needed.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Run( _
   ByVal ParamArray arguments() As String _
) 
C# 
public void Run( 
   params string[] arguments
)

Parameters

arguments

Example

Library/Library.Test/TestCmdInterpreter.cs

C#Copy Code
Assert.AreEqual(DefaultCommands.Get | DefaultCommands.Set | DefaultCommands.Help, DefaultCommands.Default);
TestCommands cmds = new TestCommands();
CommandInterpreter ci = new CommandInterpreter(cmds);
cmds.OtherData = 42;
Assert.AreEqual("42", Capture(ci, "GET Other"));
cmds.SomeData = "one-two-three";
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"));

string options = Capture(ci, "SET");
cmds.OtherData = 0;
cmds.SomeData = String.Empty;
Assert.AreEqual("0", Capture(ci, "GET Other"));
Assert.AreEqual(String.Empty, Capture(ci, "GET SomeData"));

TextReader input = Console.In;
try
{
    Console.SetIn(new StringReader(options));//feed the output of SET back to SET
    ci.Run("SET", "/readInput");
}
finally { Console.SetIn(input); }

//should now be restored
Assert.AreEqual("42", Capture(ci, "GET Other"));
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"));
VB.NETCopy Code
Assert.AreEqual(DefaultCommands.[Get] Or DefaultCommands.[Set] Or DefaultCommands.Help, DefaultCommands.[Default])
Dim cmds As New TestCommands()
Dim ci As New CommandInterpreter(cmds)
cmds.OtherData = 42
Assert.AreEqual("42", Capture(ci, "GET Other"))
cmds.SomeData = "one-two-three"
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"))

Dim options As String = Capture(ci, "SET")
cmds.OtherData = 0
cmds.SomeData = [String].Empty
Assert.AreEqual("0", Capture(ci, "GET Other"))
Assert.AreEqual([String].Empty, Capture(ci, "GET SomeData"))

Dim input As TextReader = Console.[In]
Try
    Console.SetIn(New StringReader(options))
    'feed the output of SET back to SET
    ci.Run("SET", "/readInput")
Finally
    Console.SetIn(input)
End Try

'should now be restored
Assert.AreEqual("42", Capture(ci, "GET Other"))
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys